// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsIAppStartup.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    ///This Source Code Form is subject to the terms of the Mozilla Public
    /// License, v. 2.0. If a copy of the MPL was not distributed with this
    /// file, You can obtain one at http://mozilla.org/MPL/2.0/. </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("6621f6d5-6c04-4a0e-9e74-447db221484e")]
	public interface nsIAppStartup
	{
		
		/// <summary>
        /// Create the hidden window.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void CreateHiddenWindow();
		
		/// <summary>
        /// Destroys the hidden window. This will have no effect if the hidden window
        /// has not yet been created.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void DestroyHiddenWindow();
		
		/// <summary>
        /// Runs an application event loop: normally the main event pump which
        /// defines the lifetime of the application. If there are no windows open
        /// and no outstanding calls to enterLastWindowClosingSurvivalArea this
        /// method will exit immediately.
        ///
        /// @returnCode NS_SUCCESS_RESTART_APP
        /// This return code indicates that the application should be
        /// restarted because quit was called with the eRestart flag.
        /// @returnCode NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE
        /// This return code indicates that the application should be
        /// restarted without necessarily using the same profile because
        /// quit was called with the eRestartNotSameProfile flag.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Run();
		
		/// <summary>
        /// There are situations where all application windows will be
        /// closed but we don't want to take this as a signal to quit the
        /// app. Bracket the code where the last window could close with
        /// these.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void EnterLastWindowClosingSurvivalArea();
		
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void ExitLastWindowClosingSurvivalArea();
		
		/// <summary>
        /// Whether automatic safe mode is necessary at this time.  This gets set
        /// in trackStartupCrashBegin.
        ///
        /// @see trackStartupCrashBegin
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetAutomaticSafeModeNecessaryAttribute();
		
		/// <summary>
        /// Restart the application in safe mode
        /// @param aQuitMode
        /// This parameter modifies how the app is shutdown.
        /// @see nsIAppStartup::quit
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void RestartInSafeMode(uint aQuitMode);
		
		/// <summary>
        /// If the last startup crashed then increment a counter.
        /// Set a flag so on next startup we can detect whether TrackStartupCrashEnd
        /// was called (and therefore the application crashed).
        /// @return whether safe mode is necessary
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool TrackStartupCrashBegin();
		
		/// <summary>
        /// We have succesfully started without crashing. Clear flags that were
        /// tracking past crashes.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void TrackStartupCrashEnd();
		
		/// <summary>
        /// Exit the event loop, and shut down the app.
        ///
        /// @param aMode
        /// This parameter modifies how the app is shutdown, and it is
        /// constructed from the constants defined above.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void Quit(uint aMode);
		
		/// <summary>
        /// True if the application is in the process of shutting down.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetShuttingDownAttribute();
		
		/// <summary>
        /// True if the application is in the process of starting up.
        ///
        /// Startup is complete once all observers of final-ui-startup have returned.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetStartingUpAttribute();
		
		/// <summary>
        /// Mark the startup as completed.
        ///
        /// Called at the end of startup by nsAppRunner.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void DoneStartingUp();
		
		/// <summary>
        /// True if the application is being restarted
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetRestartingAttribute();
		
		/// <summary>
        /// True if this is the startup following restart, i.e. if the application
        /// was restarted using quit(eRestart*).
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetWasRestartedAttribute();
		
		/// <summary>
        /// Returns an object with main, process, firstPaint, sessionRestored properties.
        /// Properties may not be available depending on platform or application
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		Gecko.JsVal GetStartupInfo(System.IntPtr jsContext);
		
		/// <summary>
        /// True if startup was interrupted by an interactive prompt.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetInterruptedAttribute();
		
		/// <summary>
        /// True if startup was interrupted by an interactive prompt.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetInterruptedAttribute([MarshalAs(UnmanagedType.U1)] bool aInterrupted);
	}
	
	/// <summary>nsIAppStartupConsts </summary>
	public class nsIAppStartupConsts
	{
		
		// <summary>
        // Attempt to quit if all windows are closed.
        // </summary>
		public const long eConsiderQuit = 0x01;
		
		// <summary>
        // Try to close all windows, then quit if successful.
        // </summary>
		public const long eAttemptQuit = 0x02;
		
		// <summary>
        // Quit, damnit!
        // </summary>
		public const long eForceQuit = 0x03;
		
		// <summary>
        // Restart the application after quitting.  The application will be
        // restarted with the same profile and an empty command line.
        // </summary>
		public const long eRestart = 0x10;
		
		// <summary>
        // When restarting attempt to start in the i386 architecture. Only supported
        // on OSX.
        // </summary>
		public const long eRestarti386 = 0x20;
		
		// <summary>
        // When restarting attempt to start in the x86_64 architecture. Only
        // supported on OSX.
        // </summary>
		public const long eRestartx86_64 = 0x40;
		
		// <summary>
        // Restart the application after quitting.  The application will be
        // restarted with an empty command line and the normal profile selection
        // process will take place on startup.
        // </summary>
		public const long eRestartNotSameProfile = 0x100;
	}
}
